package javase.thread.threadPool;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

public class ThreadPoolTest {

    public static void main(String[] args) {
        Future<String> submit = null;
        for (int i = 0; i < 20; i++) {
//            ThreadPoolFactory.builder().execute(new MyTask(i));
            submit = ThreadPoolFactory.builder().submit(new Callable<String>() {
                @Override
                public String call() throws Exception {
                    String str = "我执行完了";
                    return str;
                }
            });
        }

        try {
            String s = submit.get();
            System.out.println(s );
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }
    }
}
